/*
 * @Author: jhw
 * @Date: 2025-08-14 14:38:26
 * @LastEditors: jhw
 * @LastEditTime: 2025-08-22 16:53:13
 * @Description:
 */
import type { Res } from '@/types';
import request from '@/utils/request';
const prefix = '/editorApi';

// 获取所有问卷列表
export const getSurveyList = () => {
  return request({
    url: `${prefix}/surveyList`,
    method: 'get',
  });
};

// 获取分页问卷列表
export const getSurveyListByPage = (data: any): Promise<Res> => {
  return request({
    url: `${prefix}/listPage`,
    method: 'post',
    data,
  });
};

// 保存问卷
export const saveSurvey = (data: any): Promise<Res> => {
  return request({
    url: `${prefix}/save`,
    method: 'post',
    data,
  });
};

// 删除问卷
export const deleteSurvey = (id: string): Promise<Res> => {
  return request({
    url: `${prefix}/delete`,
    method: 'post',
    data: {
      id,
    },
  });
};

// 获取问卷id详情
export const getSurveyById = (id: string): Promise<Res> => {
  return request({
    url: `${prefix}/getSurveyById`,
    method: 'post',
    data: { id },
  });
};

// 获取问卷surveyId详情
export const getSurveyBySurveyId = (surveyId: string): Promise<Res> => {
  return request({
    url: `${prefix}/getSurveyBySurveyId`,
    method: 'post',
    data: { surveyId },
  });
};

// 更新问卷
export const updateSurvey = (data: any): Promise<Res> => {
  return request({
    url: `${prefix}/update`,
    method: 'post',
    data,
  });
};

// 提交问卷答案
export const submitSurveyAnswer = (data: any): Promise<Res> => {
  return request({
    url: `${prefix}/submitAnswer`,
    method: 'post',
    data,
  });
};
